const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config.dev');
const devPort = 9090;
for (let i in config.entry) {
    config.entry[i].unshift('webpack-dev-server/client?http://localhost:' + devPort, "webpack/hot/dev-server")
}
//代理服务器
const proxy = [{
    path: '/ctrade-sge/api/*', //必须得有一个文件地址，如果顶层文件夹名字不同，则用/*代替
    target: 'http://www.qilin99.com',
    host: 'www.qilin99.com',
    secure: false
}];
const server = new WebpackDevServer(webpack(config), {
    publicPath: config.output.publicPath,
    hot: true,
    host: '0.0.0.0',
    historyApiFallback: true,
    noInfo: true,
    inline: true,
    progress: true,
    stats: {
        colors: true
    },
    proxy: proxy
});
console.log(config.entry);
//将其他路由，全部返回index.html
server.app.get('*', function (req, res) {
    res.sendFile(__dirname + '/index.html')
});
server.listen(devPort, function () {
    console.log('正常打开' + devPort + '端口')
});
